-
-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker revamp #19
base: master
Are you sure you want to change the base?
Docker revamp #19
Conversation
Dashboard fix
Add Redis support
Add redis cache Drop support for unicode() Refactor StockPrice
Twitter Stream sentiment is now supported
Add test for yahoo new listener Add sh code to listen for elastic search server Add threading support
Additional news scraper change
Fix SeekingAlpha message handler
- Move interval ticker to environment variable
- Fix Readme - add env_var to allow overwrite of kibana dashboard
- - Fix copyright
- Add copyright blocks - FIx Change Log - Move sleep timer values to config.yml
src/stockprice.py
Outdated
|
||
while True: | ||
|
||
if self.isNotLive(eastern_timezone): | ||
#logger.info("Stock market is not live. Current time: %s" % datetime.datetime.now(timezone).strftime("%Y-%m-%d %H:%M")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentTime = datetime.datetime.now(timezone).strftime("%Y-%m-%d %H:%M") logger.info(f"Stock market is not live. Current time: {currentTime}")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from an outdated commit.
src/stockprice.py
Outdated
logger.info("Grabbing stock data for symbol %s..." % symbol) | ||
|
||
try: | ||
|
||
# add stock symbol to url | ||
url = re.sub("SYMBOL", symbol, url) | ||
url = regex.sub("SYMBOL", symbol, url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice touch, improves readability.
Line 61 of src/StockSight/StockPriceListener.py |
Tweets arn't showing in Kibana. |
Disable message body test for seeking alpha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review considering the amount of commits for the single pull request. Consider creating feature branches more frequently so Chris can approve them faster. Thank you for dockerizing.
src/stockprice.py
Outdated
parser.add_argument("-f", "--frequency", metavar="FREQUENCY", default=600, type=int, | ||
help="How often in seconds to retrieve stock data (default: 120 sec)") | ||
parser.add_argument("-f", "--frequency", metavar="FREQUENCY", default=price_frequency, type=int, | ||
help="How often in seconds to retrieve stock data (default: %d sec)" % price_frequency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help=f"How often in seconds to retrieve stock data (default: {price_frequency} sec)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is no longer applicable in the latest commit.
src/sentiment.py
Outdated
parser.add_argument("--frequency", metavar="FREQUENCY", default=3600, type=int, | ||
help="How often in seconds to retrieve news headlines (default: 3600 sec)") | ||
parser.add_argument("--frequency", metavar="FREQUENCY", default=sentiment_frequency, type=int, | ||
help="How often in seconds to retrieve news headlines (default: %d sec)" % sentiment_frequency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using f string instead of old school variable replacement, like so: f"How often in seconds to retrieve news headlines (default: {sentiment_frequency} sec)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is no longer applicable in the latest commit.
src/sentiment.py
Outdated
|
||
self.headlines = new_headline | ||
|
||
if len(self.followedlinks) > self.max_cache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the loop be replaced with a array slice like: self.headlines = self.headlines[self.max_cache / 2:]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is not applicable in the latest commit.
src/stockprice.py
Outdated
today = datetime.datetime.now(eastern_timezone) | ||
logger.info("Stock market is not live. Current time: %s" % today.strftime('%H')) | ||
logger.info("Stock market is not live. Current time: %s" % today.strftime("%Y-%m-%d %H:%M")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info(f"Stock market is not live. Current time { today.strftime('%Y-%m-%d %H:%M') }")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about this lol.
Python.Dockerfile
Outdated
@@ -1,4 +1,4 @@ | |||
FROM python:3 | |||
FROM python:3-alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why alpine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small image foodprint. Should I use the regular container? Regular one is probably easier to add new features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's up to you. I'm reviewing to learn more about the project and also about Docker. I haven't dockerized anything before.
src/delindex.py
Outdated
from Initializer.LoggerInit import * | ||
from Initializer.ElasticSearchInit import es | ||
from Sentiment.Initializer.ElasticSearchInit import es | ||
from Sentiment.Initializer.LoggerInit import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for alphabetizing. Good clean code principles.
src/news.sentiment.py
Outdated
@@ -11,21 +11,14 @@ | |||
""" | |||
|
|||
import argparse | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these removed because they are imported indirectly through NewsHeadlineListener? Looks a lot cleaner without all the imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya.. They imported through NewsHeadlineListener. It's suggested to remove by PyCharm.
- cluster.name=docker-cluster | ||
- cluster.name=elasticsearch | ||
- node.name=stockdata | ||
- cluster.initial_master_nodes=stockdata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It set the cluster name and node name. ElasticSearch wanted me to specify it.
|
||
|
||
if self.symbol in nltk_tokens_required: | ||
nltk_tokens = nltk_tokens_required[self.symbol] | ||
else: | ||
nltk_tokens = nltk_tokens_required['default'] | ||
|
||
# check required tokens from config | ||
tokenspass = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement in readability.
src/news.sentiment.py
Outdated
@@ -122,6 +119,7 @@ | |||
|
|||
# create instance of NewsHeadlineListener | |||
newslistener = NewsHeadlineListener(symbol, url) | |||
time.sleep(random.randrange(2,5)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the addition of a random sleep interval?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want it to have a consistent request pattern.
@caseykey Thanks for the review. However, it seems you are reviewing the older commits. There were a lot of changes and experiments on earlier commits since this is my first Python project. This pull request was submitted after I have done a lot of changes and I asked Chris' whether he's interested on dockerizing it. I initially did this as a Python practice. Submitting the pull request wasn't planned till the later stage. |
#stocksight is released under the Apache 2.0 license. See | ||
#LICENSE for the full license text. | ||
FROM python:3-alpine | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required for regex
RUN apk add build-base |
Hey Chris
Here are the list of major changes. Let me know if there are things that needed to be change.
major changes
added
current issues: